package com.gwnet.shop.controller.api;

import com.gwnet.common.log.annotation.Log;
import com.gwnet.common.log.enums.BusinessType;
import com.gwnet.shop.controller.MBaseController;
import com.gwnet.shop.domain.OrderInfo;
import com.gwnet.shop.service.IOrderInfoService;
import com.gwnet.shop.utils.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 订单Controller
 * 
 * @author 张万鹏
 * @date 2024-07-29
 */
@RestController
@RequestMapping("/api/pay")
public class PayApiController extends MBaseController
{

    @Resource
    private IOrderInfoService orderInfoService;

    /**
     * 新增订单支付
     */
    @Log(title = "订单支付完成稿的回调接口", businessType = BusinessType.INSERT)
    @PostMapping("/success")
    public AjaxResult success(@RequestBody OrderInfo orderInfo)
    {
        String orderId = orderInfo.getOrderId();
        return toAjax(orderInfoService.changeOrderStatusByOrderIdPaySuccess(orderId));
    }
}
